<template>
	<view>
		<view class="top webkit">
			<view class="left">
				<image src="../../../../static/cry.png" mode="" v-if="result == 'seckill_refund'"></image>
				<image src="../../../../static/car.png" mode="" v-else></image>
			</view>
			<view class="flex">
				<view class="title">
					<view v-if="result == 'seckill_refund'">订单支付失败</view>
					<view v-else-if="paytype == '3'">订单提交成功</view>
					<view v-else>订单支付成功</view>
				</view>
				<view>
					<view v-cloak>{{title}}</view>
				</view>
			</view>
		</view>
		<view class="info webkit" style="padding: 24upx;background: #fff;">
			<view class="mid" style="margin-right: 24upx;">
				<image src="../../../../static/dingwei.png" mode="" style="width: 32upx;height: 32upx;"></image>
			</view>
			<view class="flex">
				<view v-cloak>联系人：{{address.realname}}</view>
				<view v-cloak>联系电话：{{address.mobile}}</view>
				<view style="color: #666;" v-cloak>{{address.province}}{{address.city}}{{address.area}} {{address.address}}</view>
			</view>
		</view>
		<view class="webkit" style="padding: 12px;background: #fff;margin-top: 10px;">
			<view>实付金额</view>
			<view class="flex" style="text-align: right;color: #f55;" v-cloak>{{price}}</view>
		</view>
		<view class="webkit" style="padding: 24upx;margin-top: 20upx;">
			<!-- <button class="flex" style="margin-right: 12upx;background: #fff;" @click="detail">订单详情</button> -->
			<button class="flex" style="margin-left: 12upx;background: #fff;" @click="backindex">返回首页</button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				res:[],
				openid:"",
				orderid:"",
				result:"",
				title:'',
				paytype:"",
				price:"",
				address:[]
			};
		},
		onLoad:function(e){
			uni.showLoading()
			this.orderid = e.id
			this.result = e.result
			uni.getStorage({
				key: 'openid',
				success: (res) => {
					this.openid = res.data
					this.setAjax()
				},
				fail: () => {
					uni.navigateTo({
						url: '../login/login'
					});
				}
			});
		},
		methods:{
			setAjax(){
				uni.request({
					url: 'http://m.wpweipin.com/app/index.php?i=4&c=entry&m=ewei_shopv2&do=mobile&r=order.pay.success&app=1',
					method: 'POST',
					data: {
						openid:this.openid,
						id:this.orderid,
						result:true,
						order_pay_complete:1,
					},
					header:{'Content-Type':'application/x-www-form-urlencoded'},
					success: res => {
						console.log(res)
						uni.hideLoading()
						this.res = res.data
						this.paytype = res.data.order.paytype
						this.address = res.data.address
						this.price = res.data.order.price
						if(this.result == 'seckill_refund'){
							this.title = "支付超时，秒杀失败，系统会自动退款，如未收到退款，请联系客服！"
						}else{
							if(this.res.address != '' &&this.res.address != '0'&& this.res.order.istrade == '0'){
								this.title = '您的包裹整装待发'
							}else if(this.res.order.istrade != ''&&this.res.order.istrade != '0'){
								this.title = '您的服务已成功预约'
							}else if(this.res.order.dispatchtype != '' &&this.res.order.dispatchtype != '0' && this.res.order.isverify =='0'){
								this.title = '您可以到您选择的自提点取货了'
							}else if(this.res.order.isverify !=''&& this.res.order.isverify != '0'){
								this.title = '您可以到适用门店去使用了'
							}else if(this.res.order.virtual !=''&& this.res.order.virtual !='0'){
								this.title = '您购买的商品已自动发货'
							}else if(this.res.order.isvirtual !='' && this.res.order.isvirtual !='0' && this.res.order.virtual == '0'){
								if(this.res.order.isvirtualsend != ''){
									this.title = '您购买的商品已自动发货'
								}else{
									this.title = '您已支付成功'
								}
							}
						}
					},
					fail: () => {},
					complete: () => {}
				});
			},
			detail(){
				uni.redirectTo({
					url: '../../detail/detail?id='+this.orderid
				});
			},
			backindex(){
				uni.reLaunch({
					url:"../../../home/home"
				})
			}
		}
	}
</script>

<style>
.top{
	padding:40upx 24upx;
	background: #EB2E15;
	color: #fff;
}
.top .left image{
	width: 100upx;
	height: 100upx;
	margin: 0 24upx;
}
.top .flex .title view{
	font-size: 40upx;
	font-weight: 600;
	line-height: 60upx;
}
</style>
